home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / PredatorPrey / Help.c < prev    next >
Text File  |  1996-06-22  |  5KB  |  210 lines

  1. /* Help.c */
  2. /* Created 930503 10:02 AM by AppMaker */
  3.  
  4. #include <Types.h>
  5. #include <Quickdraw.h>
  6. #include <Controls.h>
  7. #include <Dialogs.h>
  8. #include <Events.h>
  9. #include <Lists.h>
  10. #include <Menus.h>
  11. #include <Resources.h>
  12. #include <TextEdit.h>
  13. #include <ToolUtils.h>
  14. #include "ResourceDefs.h"
  15. #include "TE32K.h"
  16. #include "Globals.h"
  17. #include "Miscellany.h"
  18. #include "Scrolling.h"
  19. #include "WindowAids.h"
  20. #include "C14CalculatorData.h"
  21. #include "GetMyHelpProc.h"
  22. #include "Help.h"
  23.  
  24. #define List1            1 
  25. #define Field2            2 
  26. #define Scroll3            3 
  27.  
  28. void    HelpSeg(void)    {}
  29.  
  30. static void BuildList1    (void);
  31.  
  32. /*----------*/
  33. static void BuildList1    ()
  34. {
  35.     Rect            bounds;
  36.  
  37.     SetWFont (List1);
  38.     GetWRect (List1, &bounds);
  39.     cur->List1HandleHelp = NewV1List (bounds, qd.thePort);    /* NewV1List in WindowAids.c */
  40.  
  41.     GetMyHelpList(cur->List1HandleHelp);
  42.  
  43. /*    AddToList ("\pOne",   cur->List1HandleHelp);    /* AddToList in WindowAids.c »*/
  44. /*    AddToList ("\pTwo",   cur->List1HandleHelp);*/
  45. /*    AddToList ("\pThree", cur->List1HandleHelp);*/
  46. /*    AddToList ("\pInfinity",  cur->List1HandleHelp);*/
  47.  
  48.     LDoDraw (true, cur->List1HandleHelp);
  49.  
  50. } /*BuildList1*/
  51.  
  52.  
  53. /*----------*/
  54. WindowPtr OpenHelp        (Str255        fName,
  55.                          short        vRefNum,
  56.                          short        fRefNum)
  57. {
  58.     WindowPtr        newWindow;
  59.     Rect            bounds;
  60.  
  61.     newWindow = GetWindow (HelpID);
  62.     if (fName [0] != 0) {
  63.         SetWTitle (newWindow, fName);
  64.     }
  65.     SetPort (newWindow);
  66.     SetNewInfo (newWindow);
  67.     cur->vScroll = nil;
  68.     cur->hScroll = nil;
  69.     cur->fileNum    = fRefNum;
  70.     cur->volNum        = vRefNum;
  71.     cur->dirty        = false;
  72.     cur->filename    = NewString (fName);
  73.     cur->windowKind = WHelp;
  74.     ((WindowPeek) curWindow)->windowKind = userKind + WHelp;
  75.     cur->witlHandle = GetResource ('Witl', HelpID);
  76.     cur->wictHandle = GetResource ('Wict', HelpID);
  77.  
  78.     BuildList1 ();
  79.     
  80.     SetWFont (Field2);
  81.     GetWRect (Field2, &bounds);
  82.     cur->Field2Handle = TENew (&bounds, &bounds);
  83.     TESetJust (textJust, cur->Field2Handle);
  84.     TEAutoView (true, cur->Field2Handle);
  85.     cur->Scroll3Handle = GetNewControl (130, newWindow);
  86.     
  87.     cur->text = cur->Field2Handle;
  88.  
  89.     ShowWindow (newWindow);
  90.     
  91.     return(newWindow);
  92.  
  93. } /*OpenHelp*/
  94.  
  95. /*----------*/
  96. void CloseHelp    (void);
  97. void CloseHelp    (void)
  98. {
  99.     LDispose (cur->List1HandleHelp);
  100.     TEDispose (cur->Field2Handle);
  101.     
  102.     DisposHandle ((Handle) cur->filename);
  103.     DiscardInfo (curWindow);
  104. } /*CloseHelp*/
  105.  
  106. /*----------*/
  107. void ControlHelp  (ControlHandle        whichControl,
  108.                          short                whichPart,
  109.                          Point                where);
  110. void ControlHelp  (ControlHandle        whichControl,
  111.                          short                whichPart,
  112.                          Point                where)
  113. {
  114.     Rect            bounds;
  115.  
  116.     if ((whichControl == (**(cur->List1HandleHelp)).vScroll)
  117.     ||  (whichControl == (**(cur->List1HandleHelp)).hScroll)) {
  118.         if (LClick (where, 0, cur->List1HandleHelp)) {
  119.             /*double click in scroll bar*/
  120.         }
  121.     }
  122.     if (whichControl == cur->Scroll3Handle) {
  123.         TrackScroll (cur->Scroll3Handle, whichPart, where, nil);
  124.     }
  125.     
  126. } /*ControlHelp*/
  127.  
  128. /*----------*/
  129. void MouseInHelp        (Point        where,
  130.                          short        modifiers);
  131. void MouseInHelp        (Point        where,
  132.                          short        modifiers)
  133. {
  134.     Rect            bounds;
  135.  
  136.     if (PtInRect (where, &(**(cur->List1HandleHelp)).rView)) {
  137.         if (LClick (where, modifiers, cur->List1HandleHelp)) {
  138.             /*double click*/
  139.         }
  140.         if (GetListChoice (&cur->List1ChoiceHelp, cur->List1HandleHelp)) {
  141.             /* something is selected */
  142.         }
  143.     }
  144.     if (PtInRect (where, &(**(cur->Field2Handle)).viewRect)) {
  145.         if (cur->text != nil) {
  146.             TEDeactivate (cur->text);
  147.         }
  148.         cur->text = cur->Field2Handle;
  149.         TEActivate (cur->text);
  150.         TEClick (where, false, cur->text);
  151.     }
  152.     
  153. } /*MouseInHelp*/
  154.  
  155. /*----------*/
  156. void TypeInHelp   (char        ch);
  157. void TypeInHelp   (char        ch)
  158. {
  159.     if (cur->text == nil) {
  160.         SysBeep (1);
  161.     } else {
  162.         TEKey (ch, cur->text);
  163.         cur->dirty = true;
  164.     }
  165. } /*TypeInHelp*/
  166.  
  167. /*----------*/
  168. void UpdateHelp (void);
  169. void UpdateHelp (void)
  170. {
  171.     Rect            bounds;
  172.  
  173.     SetWFont (List1);
  174.     LUpdate (qd.thePort->visRgn, cur->List1HandleHelp);
  175.     bounds = (**(cur->List1HandleHelp)).rView;
  176.     InsetRect (&bounds, -1, -1);
  177.     FrameRect (&bounds);
  178.  
  179.     TEUpdate (&qd.thePort->portRect, cur->Field2Handle);
  180.     
  181.     DrawClippedGrow (-15, -15);
  182. } /*UpdateHelp*/
  183.  
  184. /*----------*/
  185. /*void ActivateHelp    (Boolean    activate)*/
  186. /*{*/
  187. /*    LActivate (activate, cur->List1HandleHelp);*/
  188. /*    EnableControl (cur->Scroll3Handle, activate);*/
  189. /*    */
  190. /*    DrawClippedGrow (-15, -15);*/
  191. /*} /*ActivateHelp*/
  192.  
  193. /*----------*/
  194. void ResizeHelp    (void);
  195. void ResizeHelp    (void)
  196. {
  197.     /* application-specific code to resize items in window */
  198. } /*ResizeHelp*/
  199.  
  200. /*----------*/
  201. pascal void ScrollHelp            (short        newValue,
  202.                                   short        oldValue);
  203. pascal void ScrollHelp            (short        newValue,
  204.                                   short        oldValue)
  205. {
  206.     /* application-specific code to scroll window */
  207. } /*ScrollHelp*/
  208.  
  209. /* Help */
  210.